﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mindfor.Web.Data
{
	/// <summary>
	/// Class for folder data object.
	/// </summary>
	public class Folder : IdEntity
	{
		/// <summary>
		/// Gets or sets parent folder.
		/// </summary>
		public virtual Folder Parent { get; set; }

		/// <summary>
		/// Gets or sets owner.
		/// </summary>
		public virtual User User { get; set; }

		/// <summary>
		/// Gets or sets name.
		/// </summary>
		public virtual string Name { get; set; }

		/// <summary>
		/// Gets or sets creation date.
		/// </summary>
		public virtual DateTime CreateDate { get; set; }

		/// <summary>
		/// Gets or sets recycle date.
		/// </summary>
		public virtual DateTime? RecycleDate { get; set; }

		/// <summary>
		/// Gets or sets if folder is temporary.
		/// </summary>
		public virtual bool IsTemp { get; set; }

		/// <summary>
		/// Gets child folders.
		/// </summary>
		public virtual IList<Folder> ChildFolders { get; protected set; }

		/// <summary>
		/// Gets child files.
		/// </summary>
		public virtual IList<File> Files { get; protected set; }

		/// <summary>
		/// Initialzies new instance.
		/// </summary>
		public Folder()
		{
			CreateDate = DateTime.UtcNow;
		}

		/// <summary>
		/// Initializes new instance.
		/// </summary>
		/// <param name="name">Folder name.</param>
		public Folder(string name)
			: this()
		{
			Name = name;
		}

		/// <summary>
		/// Sets folder to be recycled in system time.
		/// </summary>
		public virtual void Recycle()
		{
			RecycleDate = DateTime.UtcNow;
		}
	}
}
